package com.systop.asset.controller;

import com.systop.asset.entity.ProcessRecord;
import com.systop.asset.entity.RestResponse;
import com.systop.asset.service.IProcessRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 审批记录Controller
 * 
 * @author mu
 * @date 2025-06-24
 */
@RestController
@RequestMapping("/asset/record")
public class ProcessRecordController{
    @Autowired
    private IProcessRecordService processRecordService;

    /**
     * 查询审批记录列表
     */
    //@PreAuthorize("@ss.hasPermi('asset:record:list')")
    @GetMapping("/list")
    public RestResponse list(ProcessRecord processRecord)
    {

        List<ProcessRecord> list = processRecordService.selectProcessRecordList(processRecord);
        return RestResponse.success(list);
    }



    /**
     * 获取审批记录详细信息
     */
    //@PreAuthorize("@ss.hasPermi('asset:record:query')")
    @GetMapping(value = "/{id}")
    public RestResponse getInfo(@PathVariable("id") Long id)
    {
        return RestResponse.success(processRecordService.selectProcessRecordById(id));
    }

    /**
     * 新增审批记录
     */
    //@PreAuthorize("@ss.hasPermi('asset:record:add')")
    @PostMapping
    public RestResponse add(@RequestBody ProcessRecord processRecord)
    {
        return RestResponse.success(processRecordService.insertProcessRecord(processRecord));
    }

    /**
     * 修改审批记录
     */
    //@PreAuthorize("@ss.hasPermi('asset:record:edit')")
    @PutMapping
    public RestResponse edit(@RequestBody ProcessRecord processRecord)
    {
        return RestResponse.success(processRecordService.updateProcessRecord(processRecord));
    }

    /**
     * 删除审批记录
     */
    //@PreAuthorize("@ss.hasPermi('asset:record:remove')")
	@DeleteMapping("/{ids}")
    public RestResponse remove(@PathVariable Long[] ids)
    {
        return RestResponse.success(processRecordService.deleteProcessRecordByIds(ids));
    }
}
